package com.example.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.example.interceptor.OneInterceptor;
import com.example.interceptor.TwoInterceptor;

/**
 * 如果继承WebMvcConfigurationSupport，会导致static目录下的html无法直接访问，比如首页Index.html，注释后即可正常访问
 * @ClassName: MyWebMvcConfigurer
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author liuwj3
 * @date 2019年2月15日 下午10:34:32
 *
 */
@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer/*extends WebMvcConfigurationSupport*/ {

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		/**
		 * 有多个拦截器时，拦截器按顺序执行
		 */
		registry.addInterceptor(new OneInterceptor()).addPathPatterns("/*/**");
		registry.addInterceptor(new TwoInterceptor()).addPathPatterns("/redis/**").addPathPatterns("/student2/**");
		WebMvcConfigurer.super.addInterceptors(registry);
	}

//	@Override
//	protected void addInterceptors(InterceptorRegistry registry) {
//		
//		/**
//		 * 有多个拦截器时，拦截器按顺序执行
//		 */
//		registry.addInterceptor(new OneInterceptor()).addPathPatterns("/*/**");
//		registry.addInterceptor(new TwoInterceptor()).addPathPatterns("/redis/**").addPathPatterns("/student2/**");
//		super.addInterceptors(registry);
//	}

	/*@Override
	protected void addViewControllers(ViewControllerRegistry registry) {
		registry.addViewController("/");
		registry.addRedirectViewController("/", "/templates/index.html");
	}*/
	
	
	
}
